package classtrain;

import java.io.*;
import java.net.Socket;
import java.util.Queue;
import java.util.Scanner;

import static java.lang.System.in;
import static java.lang.System.out;

/**
 * @DESCRIPATION
 * @AUTHOR 戴超
 * @DATE 2018/6/19
 **/
public class SendStringScoketTest {
    public static void main(String[] args) throws Exception {
        Socket client = null; //  声明Socket 对象
        client = new Socket("localhost", 8888); //  指定连接的主机和端口

        OutputStream out = client.getOutputStream();
        byte[] bytes = "asdasd312sda.".getBytes();
        out.write(bytes, 0, bytes.length);
        out.flush();

        //读取服务器返回的消息
        BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
        String mess = br.readLine();
        System.out.println("服务器：" + mess);
        System.out.println("传输完成");
        out.close();
        client.close(); //  关闭Socket

    }
}
